package com.dragon.mmochat.service;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.MmochatMain;
import com.dragon.mmochat.message.Mmochat_12_17C;
import com.dragon.mmochat.message.Mmochat_12_18S;
import com.dragon.mmochat.message.Mmochat_12_19C;
import com.dragon.mmochat.message.Mmochat_12_21C;
import com.dragon.mmochat.message.Mmochat_12_22C;
import com.dragon.mmochat.message.Mmochat_12_24C;
import com.dragon.mmochat.message.Mmochat_12_25C;
import com.dragon.mmochat.message.Mmochat_12_26C;
import com.dragon.mmochat.message.Mmochat_5_10S;
import com.dragon.mmochat.message.Mmochat_5_14S;
import com.dragon.mmochat.message.Mmochat_5_1S;
import com.dragon.mmochat.message.Mmochat_5_31S;
import com.dragon.mmochat.model.enumType.MmochatPetStateType;
import com.dragon.mmochat.model.object.MmochatCommonObject;
import com.dragon.mmochat.model.object.MmochatPackageGrid;
import com.dragon.mmochat.model.role.MmochatPet;
import com.dragon.mmochat.model.role.MmochatPlayer;
import com.dragon.mmochat.util.CreateTlvWin;
import com.dragon.mmochat.util.MmochatUtil;
import com.dragon.mmochat.util.SendBigPackUtil;
import com.google.gson.reflect.TypeToken;
import com.skymobi.handler.SkymobiHandler;
import com.skymobi.message.SkymobiProtocolMessage;
import com.skymobi.message.widget.AddDataTLV;
import com.skymobi.message.widget.ClearDataTLV;
import com.skymobi.message.widget.CloseWinTLV;
import com.skymobi.message.widget.SendDataTLV;
import com.skymobi.message.widget.ShowWaitingMsgBoxTLV;
import com.skymobi.message.widget.WinType;
import com.skymobi.service.SkymobiService;

//仓库
public class MmochatStoreService {
	// 12.21存放游戏币
	// 终端已经自行扣除了包裹中的游戏币
	@SkymobiService
	public SkymobiProtocolMessage handleC_12_21(SkymobiHandler handler,
			Mmochat_12_21C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		me.setPropNumBeforeTask();
		long money = req.getMoney();
		if (money <= 0) {
			// 更新游戏币数量
			Mmochat_5_31S pack = new Mmochat_5_31S();
			pack.setSmallMoney((int) me.getSmall_money());
			MmochatUtil.sendCommonPack(me, pack);
			return MmochatUtil.msgbox(req.getHallState(), "请输入大于0的数字!");
		}
		boolean overLoad;
		synchronized (me) {
			money = Math.min(money, me.getSmall_money());
			overLoad = false;
			if (me.getStoredSmall_money() > (long) Integer.MAX_VALUE - money) {
				money = (long) Integer.MAX_VALUE - me.getStoredSmall_money();
				me.addSmall_money(-1 * money);
				me.addStoredSmall_money(money);
				overLoad = true;
			} else {
				me.addSmall_money(-1 * money);
				me.addStoredSmall_money(money);
			}

			// 保存数据库
			try {
				MmochatDao.updateStoreMoney(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.addSmall_money(money);
				me.addStoredSmall_money(-1 * money);
				// 更新游戏币数量
				Mmochat_5_31S pack = new Mmochat_5_31S();
				pack.setSmallMoney((int) me.getSmall_money());
				MmochatUtil.sendCommonPack(me, pack);

				me.checkPropNumAfterTask("handleC_12_21,1");
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			if (overLoad) {
				// 更新游戏币数量
				Mmochat_5_31S pack = new Mmochat_5_31S();
				pack.setSmallMoney((int) me.getSmall_money());
				MmochatUtil.sendCommonPack(me, pack);
				me.checkPropNumAfterTask("handleC_12_21,2");
				return MmochatUtil.msgbox(req.getHallState(), "存款已达上限!");
			}
		}
		me.checkPropNumAfterTask("handleC_12_21,3");
		return null;
	}

	// 12.22取回游戏币
	// 终端已经自行扣除了仓库中的游戏币
	@SkymobiService
	public SkymobiProtocolMessage handleC_12_22(SkymobiHandler handler,
			Mmochat_12_22C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		me.setPropNumBeforeTask();
		long money = req.getMoney();
		if (money <= 0) {
			// 下发更新仓库金钱
			Mmochat_12_18S pack = new Mmochat_12_18S();
			pack.setStoredMoney(me.getStoredSmall_money());
			MmochatUtil.sendCommonPack(me, pack);
			return MmochatUtil.msgbox(req.getHallState(), "请输入大于0的数字!");
		}
		boolean overLoad;
		synchronized (me) {
			money = Math.min(money, me.getStoredSmall_money());
			overLoad = false;
			if (me.getSmall_money() > (long) Integer.MAX_VALUE - money) {
				money = (long) Integer.MAX_VALUE - me.getSmall_money();
				me.addSmall_money(money);
				me.addStoredSmall_money(-1 * money);
				overLoad = true;
			} else {
				me.addSmall_money(money);
				me.addStoredSmall_money(-1 * money);
			}

			// 保存数据库
			try {
				MmochatDao.updateStoreMoney(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.addSmall_money(-1 * money);
				me.addStoredSmall_money(money);
				// 下发更新仓库金钱
				Mmochat_12_18S pack = new Mmochat_12_18S();
				pack.setStoredMoney(me.getStoredSmall_money());
				MmochatUtil.sendCommonPack(me, pack);

				me.checkPropNumAfterTask("handleC_12_22,1");
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			// 更新包裹金钱
			Mmochat_5_31S pack = new Mmochat_5_31S();
			pack.setSmallMoney((int) me.getSmall_money());
			MmochatUtil.sendCommonPack(me, pack);

			if (overLoad) {
				// 下发更新仓库金钱
				Mmochat_12_18S pack1 = new Mmochat_12_18S();
				pack1.setStoredMoney(me.getStoredSmall_money());
				MmochatUtil.sendCommonPack(me, pack1);
				me.checkPropNumAfterTask("handleC_12_22,2");
				return MmochatUtil.msgbox(req.getHallState(), "您身上的金钱已达上限!");
			}
		}
		me.checkPropNumAfterTask("handleC_12_22,3");
		return null;
	}

	// 12.17 存入物品，终端没有直接从包裹中扣除物品
	@SuppressWarnings("unchecked")
	@SkymobiService
	public SkymobiProtocolMessage handleC_12_17(SkymobiHandler handler,
			Mmochat_12_17C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		me.setPropNumBeforeTask();
		MmochatCommonObject obj;
		int num;
		Map<Integer, MmochatPackageGrid> myStorageBak;
		synchronized (me) {
			MmochatPackageGrid grid = me.getMyPackage().get(req.getGridId());
			if (grid == null || grid.getObject() == null) {
				me.checkPropNumAfterTask("handleC_12_17,1");
				return null;
			}
			obj = grid.getObject();
			if (obj == null) {
				me.checkPropNumAfterTask("handleC_12_17,2");
				return null;
			}
			num = req.getNum();
			num = Math.min(num, obj.getOverlapNum());
			if (num <= 0) {
				if (MmochatConstant.isMonitorLogOpen) {
					MmochatUtil
							.monitorLog("Mmochat_12_17C error.req.getNum()="
									+ req.getNum() + ",obj.getOverlapNum()="
									+ obj.getOverlapNum() + ",roleId="
									+ me.getRoleId());
				}
				me.checkPropNumAfterTask("handleC_12_17,3");
				return null;
			}
			if (me.calRestStorageSpace(obj.getType(), obj.isCanOverlap(), obj
					.isCanDeal()) < num) {
				me.checkPropNumAfterTask("handleC_12_17,4");
				return MmochatUtil.msgbox(req.getHallState(), "仓库空间不足!");
			}
			myStorageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
					.deepClone(me.getMyStorage(),
							new TypeToken<Map<Integer, MmochatPackageGrid>>() {
							}.getType());
			if (obj.getOverlapNum() < num) {
				me.checkPropNumAfterTask("handleC_12_17,5");
				return null;
			}
			obj.delOverlapNum(num);
			MmochatCommonObject newObj = obj.getCloneWithNewId();
			newObj.setOverlapNum(num);
			me.addObjectToStorage(newObj);
			if (obj.getOverlapNum() <= 0) {
				grid.setObject(null);
			}

			try {
				MmochatDao.updateMyPackageAndStorage(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.setMyStorage(myStorageBak);
				obj.addOverlapNum(num);
				grid.setObject(obj);
				me.checkPropNumAfterTask("handleC_12_17,6");
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			Mmochat_5_1S pack = new Mmochat_5_1S();
			pack.addGrid(grid);
			me.checkPropNumAfterTask("handleC_12_17,7");
			return pack;
		}
	}

	// 12.19 取回物品，终端没有直接从仓库中扣除物品
	@SuppressWarnings("unchecked")
	@SkymobiService
	public SkymobiProtocolMessage handleC_12_19(SkymobiHandler handler,
			Mmochat_12_19C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return null;
		}
		me.setPropNumBeforeTask();
		MmochatCommonObject obj;
		int num;
		Map<Integer, MmochatPackageGrid> myPackageBak;
		List<MmochatPackageGrid> needUpdate = null;
		synchronized (me) {
			MmochatPackageGrid grid = me.getMyStorage().get(req.getGridId());
			if (grid == null || grid.getObject() == null) {
				me.checkPropNumAfterTask("handleC_12_19,1");
				return null;
			}
			obj = grid.getObject();
			num = req.getNum();
			num = Math.min(num, obj.getOverlapNum());
			if (num <= 0) {
				if (MmochatConstant.isMonitorLogOpen) {
					MmochatUtil
							.monitorLog("handleC_12_19 error.req.getNum()="
									+ req.getNum() + ",obj.getOverlapNum()="
									+ obj.getOverlapNum() + ",roleId="
									+ me.getRoleId());
				}
				me.checkPropNumAfterTask("handleC_12_19,2");
				return null;
			}
			if (me.calRestPackageSpace(obj.getType(), obj.isCanOverlap(), obj
					.isCanDeal()) < num) {
				MmochatUtil.sendCommonMsgbox(me, "包裹空间不足!");
				me.checkPropNumAfterTask("handleC_12_19,3");
				return null;
			}
			myPackageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
					.deepClone(me.getMyPackage(),
							new TypeToken<Map<Integer, MmochatPackageGrid>>() {
							}.getType());
			if (obj.getOverlapNum() < num) {
				me.checkPropNumAfterTask("handleC_12_19,4");
				return null;
			}
			obj.delOverlapNum(num);
			MmochatCommonObject newObj = obj.getCloneWithNewId();
			newObj.setOverlapNum(num);
			needUpdate = me.addObjectToPackage(newObj, false);
			if (obj.getOverlapNum() <= 0) {
				grid.setObject(null);
			}

			try {
				MmochatDao.updateMyPackageAndStorage(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.setMyPackage(myPackageBak);
				obj.addOverlapNum(num);
				grid.setObject(obj);
				MmochatUtil.sendCommonMsgbox(me, "服务器忙,请稍候再试!");

				me.checkPropNumAfterTask("handleC_12_19,5");
				return null;
			}
			// 更新包裹
			Mmochat_5_1S pack1 = new Mmochat_5_1S();
			pack1.setGrids(needUpdate);
			MmochatUtil.sendCommonPack(me, pack1);

			// 下发更新仓库格子
			Mmochat_12_18S pack = new Mmochat_12_18S();
			pack.setStoredMoney(me.getStoredSmall_money());
			pack.addGrid(grid);
			me.checkPropNumAfterTask("handleC_12_19,6");
			return pack;
		}

	}

	// 12.24 存入宠物
	@SkymobiService
	public SkymobiProtocolMessage handleC_12_24(SkymobiHandler handler,
			Mmochat_12_24C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatPet pet = null;
		synchronized (me) {
			pet = me.getPetAlongById(req.getPetId());
			if (pet == null) {
				return null;
			}
			if (me.isPetStorageFull()) {
				return MmochatUtil.msgbox(req.getHallState(), "宠物仓库已满!");
			}
			if (pet.getState() != MmochatPetStateType.休息) {
				return MmochatUtil.msgbox(req.getHallState(),
						"该宠物当前为参战状态，无法存入!请先设为休息状态。");
			}

			if (me.isPetStorageFull()) {
				return MmochatUtil.msgbox(req.getHallState(), "宠物仓库已满!");
			}
			me.delPet(pet.getId());
			me.getStoredPets().put(pet.getId(), pet);

			try {
				MmochatDao.updateRolePetsAfterStore(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.addPet(pet);
				me.getStoredPets().remove(pet.getId());
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
		}
		Mmochat_5_14S pack = new Mmochat_5_14S();
		pack.setDelPetId(pet.getId());
		return pack;
	}

	// 12.25 取回宠物
	@SkymobiService
	public SkymobiProtocolMessage handleC_12_25(SkymobiHandler handler,
			Mmochat_12_25C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		if (me.isPetFull()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您当前携带的宠物数已达上限，请先存放部分宠物后再操作!");
		}

		MmochatPet pet = null;
		synchronized (me) {
			if (me.isPetFull()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您当前携带的宠物数已达上限，请先存放部分宠物后再操作!");
			}

			pet = me.getStoredPets().get(req.getPetId());
			if (pet == null) {
				return MmochatUtil.msgbox(req.getHallState(), "该宠物不存在!");
			}
			if (me.isPetFull()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您当前携带的宠物数已达上限，请先存放部分宠物后再操作!");
			}
			me.getStoredPets().remove(pet.getId());
			pet.setState(MmochatPetStateType.休息);
			me.addPet(pet);
		}
		try {
			MmochatDao.updateRolePetsAfterStore(me);
		} catch (Exception e) {
			e.printStackTrace();
			me.delPet(pet.getId());
			me.getStoredPets().put(pet.getId(), pet);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		Mmochat_5_10S pack = new Mmochat_5_10S();
		pack.addPet(pet);
		MmochatUtil.sendCommonPack(me, pack);

		CreateTlvWin tlv = MmochatStoreService.getStoredPetList(me);
		return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
				MmochatConstant.TLV_WIN_FETCHPET_FROMSTORE), tlv);
	}

	public static CreateTlvWin getStoredPetList(MmochatPlayer me) {
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.List);
		tlv.setRightName("返回");
		tlv.setLeftName("取回");
		tlv.setTitle("宠物仓库");
		tlv.setWinHeight(188);
		tlv.setWinId(MmochatConstant.TLV_WIN_FETCHPET_FROMSTORE);
		tlv.addRightTLV(new CloseWinTLV(
				MmochatConstant.TLV_WIN_FETCHPET_FROMSTORE));

		for (MmochatPet pet : me.getStoredPets().values()) {
			String item = MmochatUtil.wrapColor(pet.getName() + "\n",
					Color.yellow);
			item += "等级:" + pet.getLevel() + "级\n";
			item += "武学:" + pet.getDao() + "\n";
			item += "种类:" + pet.getRoleType().toString() + "\n";
			item += "品质:" + pet.getPetType().toString();
			tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV((int) pet
					.getId()));
		}
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_12_25, (int) me.getRoleId()));
		ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
		tlv.addLeftTLV(wait);
		return tlv;
	}

	// 整理仓库
	@SuppressWarnings("unchecked")
	public static void orderStorage(MmochatPlayer me) {
		if (!MmochatConstant.isStorageWapOpen) {
			return;
		}
		if (me == null) {
			return;
		}

		if (!me.canOrderStorage()) {
			return;
		}
		me.setLastOrderStorageTick(System.currentTimeMillis());
		me.setPropNumBeforeTask();
		synchronized (me) {
			// 同类物品，如果可叠加，则尽量叠加
			// 排序：药品、道具、装备、材料、法宝
			Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
					.deepClone(me.getMyStorage(),
							new TypeToken<Map<Integer, MmochatPackageGrid>>() {
							}.getType());
			List<MmochatCommonObject> drugList = new ArrayList<MmochatCommonObject>();
			List<MmochatCommonObject> propList = new ArrayList<MmochatCommonObject>();
			List<MmochatCommonObject> equipList = new ArrayList<MmochatCommonObject>();
			List<MmochatCommonObject> materialList = new ArrayList<MmochatCommonObject>();
			List<MmochatCommonObject> machineList = new ArrayList<MmochatCommonObject>();
			List<MmochatCommonObject> otherList = new ArrayList<MmochatCommonObject>();
			for (MmochatPackageGrid grid : me.getMyStorage().values()) {
				if (!grid.isCanUse()) {
					continue;
				}
				if (grid != null && grid.getObject() != null) {
					MmochatCommonObject obj = grid.getObject();
					switch (obj.getObjectType()) {
					case 药品: {
						drugList.add(obj);
						break;
					}
					case 装备: {
						equipList.add(obj);
						break;
					}
					case 材料: {
						materialList.add(obj);
						break;
					}
					case 道具: {
						propList.add(obj);
						break;
					}
					case 法宝: {
						machineList.add(obj);
						break;
					}
					default:
						otherList.add(obj);
						break;
					}
				}
				grid.setObject(null);
			}

			for (MmochatCommonObject machine : machineList) {
				me.addObjectToStorage(machine);
			}
			if (drugList.size() > 0) {
				// 药品排序
				List<MmochatCommonObject> drugs = new ArrayList<MmochatCommonObject>(
						drugList);
				Collections.sort(drugs, new MmochatCommonObject.sortDrug());
				for (MmochatCommonObject drug : drugs) {
					me.addObjectToStorage(drug);
				}
			}
			if (propList.size() > 0) {
				Collections.sort(propList, new MmochatCommonObject.sortProp());
				for (MmochatCommonObject prop : propList) {
					me.addObjectToStorage(prop);
				}
			}
			if (equipList.size() > 0) {
				for (MmochatCommonObject equip : equipList) {
					me.addObjectToStorage(equip);
				}
			}
			if (materialList.size() > 0) {
				List<MmochatCommonObject> materials = new ArrayList<MmochatCommonObject>(
						materialList);
				Collections.sort(materials,
						new MmochatCommonObject.sortMaterial());
				for (MmochatCommonObject material : materials) {
					me.addObjectToStorage(material);
				}
			}
			for (MmochatCommonObject other : otherList) {
				me.addObjectToStorage(other);
			}
			try {
				MmochatDao.updateMyStorage(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.setMyStorage(packageBak);
			}
			me.checkPropNumAfterTask("handleC_12_26,2");
		}
	}

	// 申请整理仓库
	@SkymobiService
	public SkymobiProtocolMessage handleC_12_26(SkymobiHandler handler,
			Mmochat_12_26C req) {
		return MmochatUtil.msgbox(req.getHallState(), "仓库整理功能暂时关闭!");
		/*
		 * MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
		 * .getRoleId()); if (me == null) { return
		 * MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!"); }
		 * 
		 * if (!me.canOrderStorage()) { return
		 * MmochatUtil.msgbox(req.getHallState(), "请" + me.getRestOrderSec() +
		 * "秒后再整理仓库!"); }
		 * me.setLastOrderStorageTick(System.currentTimeMillis());
		 * me.setPropNumBeforeTask(); synchronized (me) { // 同类物品，如果可叠加，则尽量叠加 //
		 * 排序：药品、道具、装备、材料、法宝 Map<Integer, MmochatPackageGrid> packageBak =
		 * (Map<Integer, MmochatPackageGrid>) MmochatUtil
		 * .deepClone(me.getMyStorage(), new TypeToken<Map<Integer,
		 * MmochatPackageGrid>>() { }.getType()); List<MmochatCommonObject>
		 * drugList = new ArrayList<MmochatCommonObject>();
		 * List<MmochatCommonObject> propList = new
		 * ArrayList<MmochatCommonObject>(); List<MmochatCommonObject> equipList
		 * = new ArrayList<MmochatCommonObject>(); List<MmochatCommonObject>
		 * materialList = new ArrayList<MmochatCommonObject>();
		 * List<MmochatCommonObject> machineList = new
		 * ArrayList<MmochatCommonObject>(); List<MmochatCommonObject> otherList
		 * = new ArrayList<MmochatCommonObject>(); for (MmochatPackageGrid grid
		 * : me.getMyStorage().values()) { if (!grid.isCanUse()) { continue; }
		 * if (grid != null && grid.getObject() != null) { MmochatCommonObject
		 * obj = grid.getObject(); switch (obj.getObjectType()) { case 药品: {
		 * drugList.add(obj); break; } case 装备: { equipList.add(obj); break; }
		 * case 材料: { materialList.add(obj); break; } case 道具: {
		 * propList.add(obj); break; } case 法宝: { machineList.add(obj); break; }
		 * default: otherList.add(obj); break; } } grid.setObject(null); }
		 * 
		 * for (MmochatCommonObject machine : machineList) {
		 * me.addObjectToStorage(machine); } if (drugList.size() > 0) { // 药品排序
		 * List<MmochatCommonObject> drugs = new ArrayList<MmochatCommonObject>(
		 * drugList); Collections.sort(drugs, new
		 * MmochatCommonObject.sortDrug()); for (MmochatCommonObject drug :
		 * drugs) { me.addObjectToStorage(drug); } } if (propList.size() > 0) {
		 * Collections.sort(propList, new MmochatCommonObject.sortProp()); for
		 * (MmochatCommonObject prop : propList) { me.addObjectToStorage(prop);
		 * } } if (equipList.size() > 0) { for (MmochatCommonObject equip :
		 * equipList) { me.addObjectToStorage(equip); } } if
		 * (materialList.size() > 0) { List<MmochatCommonObject> materials = new
		 * ArrayList<MmochatCommonObject>( materialList);
		 * Collections.sort(materials, new MmochatCommonObject.sortMaterial());
		 * for (MmochatCommonObject material : materials) {
		 * me.addObjectToStorage(material); } } for (MmochatCommonObject other :
		 * otherList) { me.addObjectToStorage(other); } try {
		 * MmochatDao.updateMyStorage(me); } catch (Exception e) {
		 * e.printStackTrace(); me.setMyStorage(packageBak);
		 * me.checkPropNumAfterTask("handleC_12_26,1"); return
		 * MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!"); }
		 * SendBigPackUtil.sendBigPack_12_18S(me, me.getMyStorage().values());
		 * me.checkPropNumAfterTask("handleC_12_26,2"); } return null;
		 */
	}
}
